package com.hx.redis;

import com.hx.service.UserService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.util.List;

public class ListRedisTemplate {
    /**
     * 测试list
     */
    @Test
    public  void t1() {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = ctx.getBean(UserService.class);
        //初始化数据
        userService.listAdd();
        int pageSize =3;
        int pageNum = 2;
        List<String> list = (List<String>) userService.listRange(pageNum,pageSize);
        for(String s:list) {
            System.out.println(s);
        }
    }
    @Test
    public  void t2() {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = ctx.getBean(UserService.class);
        //初始化数据
        String cardId = "A0001";
        //userService.listQueueinit(cardId);

        System.out.println("------当前需要执行的任务队列：");
        List<String> list1 = userService.listQueueWait(cardId);
        for (String  s:list1){
            System.out.println(s);
        }
        System.out.println("------物流小哥开始运输物流信息：");
        userService.listQueueTouch(cardId);

        System.out.println("------小哥操作后当前待执行的任务队列：");
        List<String> list3 = userService.listQueueWait(cardId);
        for (String  s:list3){
            System.out.println(s);
        }
        System.out.println("------已完成的任务队列：");
        List<String> list2 = userService.listQueueSucc(cardId);
        for (String  s:list2){
            System.out.println(s);
        }

    }
}
